﻿@using Smartstore.Web.Models.Search

@model SearchResultModel

@{
    var hasThumbs = Model.TopProducts.Items.Any(x => x.Image?.File != null);
}

<ul class="instasearch-hits@(hasThumbs ? " has-thumbs" : "")">
    @foreach (var hit in Model.TopProducts.Items)
    {
        <li>
            <a class="instasearch-hit" asp-route="Product" asp-route-SeName="@hit.SeName" asp-area="">
                <span class="instasearch-hit-wrapper">
                    <span sm-if="hasThumbs && hit.Image?.File != null" class="instasearch-hit-thumb d-block">
                        <img sm-model="@hit.Image" class="img-fluid" />
                    </span>
                    <span class="d-block text-truncate">
                        <span class="d-block text-truncate" sm-language-attributes-for="hit.Name">
                            @Html.Raw(Model.Highlight(hit.Name, "name", Model.Query, null, "<span class='instasearch-match'>", "</span>"))
                        </span>
                        @if (hasThumbs && hit.ShortDescription.Value.HasValue())
                        {
                            <span class="instasearch-hit-label-secondary d-block text-truncate" sm-language-attributes-for="hit.ShortDescription">
                                @hit.ShortDescription.Value.RemoveHtml()
                            </span>
                        }
                    </span>
                </span>
            </a>
        </li>
    }
</ul>